#define _CRT_SECURE_NO_WARNINGS 1

class Solution {
public:
    int minOperations(vector<int>& nums, int k) {
        using LL = long long;
        priority_queue<LL, deque<LL>, greater<LL>> heap;
        for (auto& e : nums)
        {
            heap.push(e);
        }
        int res = 0;
        while (heap.size() > 1 && heap.top() < k)
        {
            LL a = heap.top(); heap.pop();
            LL b = heap.top(); heap.pop();
            LL c = min(a, b) * 2 + max(a, b);
            heap.push(c);
            ++res;
        }
        return res;
    }
};